using System.Collections.Generic;
using UnityEngine;

namespace Skills
{
    public enum ERange
    {
        Point,
        Around,
        Box,
        Circle,
        Cross,
    }

    [System.Serializable]
    public class Range
    {
        [SerializeField]
        internal int innerRadius;
        [SerializeField]
        internal int outerRadius;
        [SerializeField]
        internal ERange shape;
        [SerializeField]
        internal List<Vector2Int> positions = new List<Vector2Int>() { Vector2Int.zero };

        public bool Contain(Vector2Int relativePosition)
        {
            float distance = 0f;
            switch (shape)
            {
                case ERange.Point:
                    return relativePosition == Vector2Int.zero;
                case ERange.Box:
                case ERange.Around:
                    distance = Mathf.Max(Mathf.Abs(relativePosition.x), Mathf.Abs(relativePosition.y));
                    break;
                case ERange.Circle:
                    distance = relativePosition.magnitude;
                    break;
                case ERange.Cross:
                    distance = GeometryTool.ManhattanDistanceInt(relativePosition, Vector2Int.zero);
                    break;
            }
            return distance <= outerRadius && distance >= innerRadius;
        }
    }
}

